package com.java.base.exercise.designmode.proxy.jdkproxy.proxyimpl;

import net.sf.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

/**
 * @Author RenPu
 * @Date 2022/6/20 14:44
 * @Version 1.0
 * @Description: JDK代理模式InvocationHandler
 **/
public class JDKInvocation implements InvocationHandler {


    /**
     * 代理类的目标对象
     */
    private final Object target;

    public JDKInvocation(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object o, Method method, Object[] args) throws Throwable {
        System.out.println("JDK动态代理模式：-----开启触发后  ^_^-----");   //业务逻辑增强的前置处理
        Object result= method.invoke(target,args);
        System.out.println("JDK动态代理模式：-----开启触发后  O(∩_∩)O哈哈~-----");  //业务逻辑增强的后置处理
        return result;
    }
}
